home *** CD-ROM | disk | FTP | other *** search
/ Financial Peace University Interactive Bonus / Financial Peace University Bonus Interactive CD-ROM.iso / pc / calculators / futureValue.swf / scripts / __Packages / mx / screens / Slide.as < prev   
Encoding:
Text File  |  2006-02-07  |  18.8 KB  |  708 lines

  1. class mx.screens.Slide extends mx.screens.Screen
  2. {
  3.    var _childSlides;
  4.    var addEventListener;
  5.    static var symbolName = "Slide";
  6.    static var symbolOwner = mx.screens.Slide;
  7.    var className = "Slide";
  8.    var _isSlide = true;
  9.    var _currentChildSlide = null;
  10.    var _currentSlide = null;
  11.    var _indexInParentSlide = -1;
  12.    var _childThatContainsGotoSlide = -1;
  13.    var _defaultKeyDownHandler = null;
  14.    var _shown = false;
  15.    static var _disableArrowKeys = false;
  16.    static var _focusFixup = null;
  17.    static var _gotoSlideNesting = 0;
  18.    var _laterGotoSlide = null;
  19.    static var _inKeyDown = false;
  20.    static var _focusSeq = 0;
  21.    static var _clickFocusSeq = 0;
  22.    var autoKeyNav = "inherit";
  23.    var overlayChildren = false;
  24.    var playHidden = true;
  25.    function Slide()
  26.    {
  27.       super();
  28.    }
  29.    function get currentChildSlide()
  30.    {
  31.       return this._currentChildSlide;
  32.    }
  33.    function get currentSlide()
  34.    {
  35.       return this._currentSlide;
  36.    }
  37.    static function get currentFocusedSlide()
  38.    {
  39.       var curFocus;
  40.       curFocus = _root.focusManager.getFocus();
  41.       if(!curFocus || curFocus == undefined)
  42.       {
  43.          curFocus = eval(Selection.getFocus());
  44.       }
  45.       while(curFocus && !curFocus._isSlide)
  46.       {
  47.          curFocus = curFocus._parent;
  48.       }
  49.       if(curFocus == undefined)
  50.       {
  51.          return null;
  52.       }
  53.       return mx.screens.Slide(curFocus);
  54.    }
  55.    function get defaultKeyDownHandler()
  56.    {
  57.       return this._defaultKeyDownHandler;
  58.    }
  59.    function set defaultKeyDownHandler(newHandler)
  60.    {
  61.       this._defaultKeyDownHandler = newHandler;
  62.    }
  63.    function get firstSlide()
  64.    {
  65.       var _loc2_ = this;
  66.       while(_loc2_.numChildSlides > 0)
  67.       {
  68.          _loc2_ = _loc2_.getChildSlide(0);
  69.       }
  70.       return _loc2_;
  71.    }
  72.    function get lastSlide()
  73.    {
  74.       var _loc2_ = this;
  75.       while(_loc2_.numChildSlides > 0)
  76.       {
  77.          _loc2_ = _loc2_.getChildSlide(_loc2_.numChildSlides - 1);
  78.       }
  79.       return _loc2_;
  80.    }
  81.    function get indexInParentSlide()
  82.    {
  83.       return this._indexInParentSlide;
  84.    }
  85.    function get nextSlide()
  86.    {
  87.       var _loc2_ = this;
  88.       while(true)
  89.       {
  90.          if(!_loc2_.parentIsSlide)
  91.          {
  92.             break;
  93.          }
  94.          if(_loc2_.indexInParentSlide != _loc2_.parentSlide.numChildSlides - 1)
  95.          {
  96.             _loc2_ = _loc2_.parentSlide.getChildSlide(_loc2_.indexInParentSlide + 1);
  97.             break;
  98.          }
  99.          _loc2_ = _loc2_.parentSlide;
  100.       }
  101.       if(!_loc2_.parentIsSlide)
  102.       {
  103.          return null;
  104.       }
  105.       _loc2_ = _loc2_.firstSlide;
  106.       return _loc2_;
  107.    }
  108.    function get numChildSlides()
  109.    {
  110.       return this._childSlides.length;
  111.    }
  112.    function get parentIsSlide()
  113.    {
  114.       return this.parentSlide != null && this.parentSlide._isSlide;
  115.    }
  116.    function get parentSlide()
  117.    {
  118.       var _loc2_ = this._parent;
  119.       while(true)
  120.       {
  121.          if(_loc2_ == null)
  122.          {
  123.             return null;
  124.          }
  125.          if(!_loc2_._isSlideContainer)
  126.          {
  127.             if(_loc2_._isSlide)
  128.             {
  129.                return mx.screens.Slide(_loc2_);
  130.             }
  131.             return null;
  132.          }
  133.          _loc2_ = _loc2_._parent;
  134.       }
  135.    }
  136.    function get previousSlide()
  137.    {
  138.       var _loc2_ = this;
  139.       while(true)
  140.       {
  141.          if(!_loc2_.parentIsSlide)
  142.          {
  143.             break;
  144.          }
  145.          if(_loc2_.indexInParentSlide != 0)
  146.          {
  147.             _loc2_ = _loc2_.parentSlide.getChildSlide(_loc2_.indexInParentSlide - 1);
  148.             break;
  149.          }
  150.          _loc2_ = _loc2_.parentSlide;
  151.       }
  152.       if(!_loc2_.parentIsSlide)
  153.       {
  154.          return null;
  155.       }
  156.       _loc2_ = _loc2_.lastSlide;
  157.       return _loc2_;
  158.    }
  159.    function get rootSlide()
  160.    {
  161.       var _loc2_ = this;
  162.       while(_loc2_.parentIsSlide)
  163.       {
  164.          _loc2_ = _loc2_.parentSlide;
  165.       }
  166.       return _loc2_;
  167.    }
  168.    function getChildSlide(childIndex)
  169.    {
  170.       return this._childSlides[childIndex];
  171.    }
  172.    function gotoFirstSlide()
  173.    {
  174.       if(this.firstSlide == null)
  175.       {
  176.          return false;
  177.       }
  178.       return this.gotoSlide(this.firstSlide);
  179.    }
  180.    function gotoLastSlide()
  181.    {
  182.       if(this.lastSlide == null)
  183.       {
  184.          return false;
  185.       }
  186.       return this.gotoSlide(this.lastSlide);
  187.    }
  188.    function gotoNextSlide()
  189.    {
  190.       if(this.nextSlide == null)
  191.       {
  192.          return false;
  193.       }
  194.       return this.gotoSlide(this.nextSlide);
  195.    }
  196.    function gotoPreviousSlide()
  197.    {
  198.       if(!this.previousSlide)
  199.       {
  200.          return false;
  201.       }
  202.       return this.gotoSlide(this.previousSlide);
  203.    }
  204.    function gotoSlide(newSlide)
  205.    {
  206.       if(mx.screens.Slide._gotoSlideNesting > 0)
  207.       {
  208.          this._laterGotoSlide = newSlide;
  209.          this.doLater(this,"doLaterGotoSlide");
  210.          return false;
  211.       }
  212.       mx.screens.Slide._gotoSlideNesting = mx.screens.Slide._gotoSlideNesting + 1;
  213.       if(newSlide == null)
  214.       {
  215.          mx.screens.Slide._gotoSlideNesting--;
  216.          return false;
  217.       }
  218.       var _loc5_ = newSlide;
  219.       var _loc9_ = 0;
  220.       while(true)
  221.       {
  222.          _loc5_._childThatContainsGotoSlide = _loc9_;
  223.          _loc9_ = _loc5_.indexInParentSlide;
  224.          if(!_loc5_.parentIsSlide)
  225.          {
  226.             break;
  227.          }
  228.          _loc5_ = _loc5_.parentSlide;
  229.       }
  230.       var _loc2_ = null;
  231.       var _loc10_ = null;
  232.       var _loc4_ = undefined;
  233.       if(this.rootSlide.currentSlide == null)
  234.       {
  235.          _loc2_ = this.rootSlide;
  236.          _loc10_ = _loc2_;
  237.       }
  238.       else
  239.       {
  240.          _loc2_ = this.rootSlide.currentSlide;
  241.          _loc10_ = _loc2_;
  242.          while(_loc2_._childThatContainsGotoSlide == -1)
  243.          {
  244.             if(_loc2_.parentIsSlide)
  245.             {
  246.                if(_loc2_.parentSlide._childThatContainsGotoSlide == -1)
  247.                {
  248.                   if(_loc2_.shouldHideDuringGoto())
  249.                   {
  250.                      if(_loc2_.parentSlide.overlayChildren)
  251.                      {
  252.                         _loc4_ = 0;
  253.                         while(_loc4_ <= _loc2_.indexInParentSlide)
  254.                         {
  255.                            _loc2_.parentSlide.getChildSlide(_loc4_).hideSlide();
  256.                            _loc4_ = _loc4_ + 1;
  257.                         }
  258.                      }
  259.                      else
  260.                      {
  261.                         _loc2_.hideSlide();
  262.                      }
  263.                   }
  264.                }
  265.                else if(!_loc2_.parentSlide.overlayChildren)
  266.                {
  267.                   _loc2_.hideSlide();
  268.                }
  269.                else
  270.                {
  271.                   _loc4_ = _loc2_.parentSlide._childThatContainsGotoSlide + 1;
  272.                   while(_loc4_ <= _loc2_.indexInParentSlide)
  273.                   {
  274.                      _loc2_.parentSlide.getChildSlide(_loc4_).hideSlide();
  275.                      _loc4_ = _loc4_ + 1;
  276.                   }
  277.                }
  278.             }
  279.             if(!_loc2_.parentIsSlide)
  280.             {
  281.                break;
  282.             }
  283.             _loc2_ = _loc2_.parentSlide;
  284.          }
  285.       }
  286.       if(_loc2_._childThatContainsGotoSlide == -1)
  287.       {
  288.          mx.screens.Slide._gotoSlideNesting--;
  289.          return false;
  290.       }
  291.       var _loc3_ = _loc10_;
  292.       while(true)
  293.       {
  294.          _loc3_._currentSlide = null;
  295.          _loc3_._currentChildSlide = null;
  296.          if(!_loc3_.parentIsSlide)
  297.          {
  298.             break;
  299.          }
  300.          _loc3_ = _loc3_.parentSlide;
  301.       }
  302.       _loc3_ = newSlide;
  303.       var _loc6_ = null;
  304.       while(true)
  305.       {
  306.          _loc3_._currentSlide = newSlide;
  307.          _loc3_._currentChildSlide = _loc6_;
  308.          if(!_loc3_.parentIsSlide)
  309.          {
  310.             break;
  311.          }
  312.          _loc6_ = _loc3_;
  313.          _loc3_ = _loc3_.parentSlide;
  314.       }
  315.       _loc2_.showSlide();
  316.       while(_loc2_ != newSlide)
  317.       {
  318.          var _loc8_ = _loc2_.getChildSlide(_loc2_._childThatContainsGotoSlide);
  319.          if(_loc8_ == null)
  320.          {
  321.             break;
  322.          }
  323.          if(_loc2_.overlayChildren)
  324.          {
  325.             _loc4_ = 0;
  326.             while(_loc4_ < _loc2_._childThatContainsGotoSlide)
  327.             {
  328.                _loc2_._childSlides[_loc4_].showSlide();
  329.                _loc4_ = _loc4_ + 1;
  330.             }
  331.          }
  332.          _loc2_ = _loc8_;
  333.          _loc2_.showSlide();
  334.       }
  335.       if(this.rootSlide.allAncestorsVisible())
  336.       {
  337.          if(mx.screens.Slide._inKeyDown)
  338.          {
  339.             this.doLater(newSlide,"setFocus");
  340.          }
  341.          else
  342.          {
  343.             newSlide.setFocus();
  344.          }
  345.       }
  346.       _loc3_ = _loc10_;
  347.       while(true)
  348.       {
  349.          _loc3_._currentSlide = null;
  350.          _loc3_._currentChildSlide = null;
  351.          _loc3_._childThatContainsGotoSlide = -1;
  352.          if(!_loc3_.parentIsSlide)
  353.          {
  354.             break;
  355.          }
  356.          _loc3_ = _loc3_.parentSlide;
  357.       }
  358.       _loc3_ = newSlide;
  359.       _loc6_ = null;
  360.       while(true)
  361.       {
  362.          _loc3_._currentSlide = newSlide;
  363.          _loc3_._currentChildSlide = _loc6_;
  364.          _loc3_._childThatContainsGotoSlide = -1;
  365.          if(!_loc3_.parentIsSlide)
  366.          {
  367.             break;
  368.          }
  369.          _loc6_ = _loc3_;
  370.          _loc3_ = _loc3_.parentSlide;
  371.       }
  372.       mx.screens.Slide._gotoSlideNesting--;
  373.       return true;
  374.    }
  375.    function doLaterGotoSlide()
  376.    {
  377.       this.gotoSlide(this._laterGotoSlide);
  378.    }
  379.    function init()
  380.    {
  381.       this._childSlides = [];
  382.       this.doLater(this,"stop");
  383.       super.init();
  384.       this.tabEnabled = false;
  385.       this.focusEnabled = true;
  386.       this._visible = false;
  387.       if(mx.screens.Slide._focusFixup == null)
  388.       {
  389.          mx.screens.Slide._focusFixup = new Object();
  390.          mx.screens.Slide._focusFixup.onSetFocus = function(o, n)
  391.          {
  392.             mx.screens.Slide._focusSeq = mx.screens.Slide._focusSeq + 1;
  393.             if(n != null && typeof n != "movieclip" && !n._isSlide)
  394.             {
  395.                mx.screens.Slide._disableArrowKeys = true;
  396.             }
  397.             else
  398.             {
  399.                mx.screens.Slide._disableArrowKeys = false;
  400.             }
  401.          };
  402.          Selection.addListener(mx.screens.Slide._focusFixup);
  403.          mx.screens.Slide._focusFixup.onKeyDown = function(Void)
  404.          {
  405.             var _loc1_ = {type:"keyDown",code:Key.getCode(),ascii:Key.getAscii(),shiftKey:Key.isDown(16),ctrlKey:Key.isDown(17)};
  406.             mx.screens.Slide._inKeyDown = true;
  407.             if(mx.screens.Slide.currentFocusedSlide.useDefaultKeyDownHandler())
  408.             {
  409.                mx.screens.Slide.currentFocusedSlide.callDefaultKeyDownHandler(_loc1_);
  410.             }
  411.             mx.screens.Slide._inKeyDown = false;
  412.          };
  413.          Key.addListener(mx.screens.Slide._focusFixup);
  414.       }
  415.       if(this._parent._name != this._parent._parent._childLoading)
  416.       {
  417.          if(!this.parentIsSlide)
  418.          {
  419.             this._defaultKeyDownHandler = this.autoKeyDownHandler;
  420.             this.addEventListener("mouseDownSomewhere",this);
  421.             this.doLater(this,"gotoFirstSlide");
  422.          }
  423.          else if(this.parentSlide && this.parentSlide._isSlide)
  424.          {
  425.             this.parentSlide.registerChildSlide(this);
  426.          }
  427.       }
  428.    }
  429.    function registerChildSlide(slide)
  430.    {
  431.       slide._indexInParentSlide = this._childSlides.push(slide) - 1;
  432.    }
  433.    function useDefaultKeyDownHandler()
  434.    {
  435.       var _loc2_ = this;
  436.       while(_loc2_.parentIsSlide && _loc2_.autoKeyNav == "inherit")
  437.       {
  438.          _loc2_ = _loc2_.parentSlide;
  439.       }
  440.       var _loc3_ = undefined;
  441.       _loc3_ = _loc2_.autoKeyNav == "true" || _loc2_.autoKeyNav == "inherit";
  442.       return _loc3_;
  443.    }
  444.    function callDefaultKeyDownHandler(o)
  445.    {
  446.       var _loc2_ = this;
  447.       while(_loc2_.parentIsSlide && _loc2_.defaultKeyDownHandler == null)
  448.       {
  449.          _loc2_ = _loc2_.parentSlide;
  450.       }
  451.       if(_loc2_.defaultKeyDownHandler)
  452.       {
  453.          _loc2_.defaultKeyDownHandler.call(_loc2_,o);
  454.       }
  455.    }
  456.    function autoKeyDownHandler(o)
  457.    {
  458.       if(!mx.screens.Slide._disableArrowKeys)
  459.       {
  460.          switch(o.code)
  461.          {
  462.             case 32:
  463.                if(this.getFocusManager().bDrawFocus)
  464.                {
  465.                   break;
  466.                }
  467.             case 39:
  468.                this.currentSlide.gotoNextSlide();
  469.                break;
  470.             case 37:
  471.                this.currentSlide.gotoPreviousSlide();
  472.          }
  473.       }
  474.    }
  475.    function allTransitionsOutDone(o)
  476.    {
  477.       super.allTransitionsOutDone(o);
  478.       if(this == this.currentSlide)
  479.       {
  480.          this.setFocus();
  481.       }
  482.    }
  483.    function showSlide()
  484.    {
  485.       if(this._visible && this.__transitionManager.numOutTransitions > 0)
  486.       {
  487.          this._visible = false;
  488.          this.__transitionManager.removeAllTransitions();
  489.          this.__transitionManager.restoreContentAppearance();
  490.       }
  491.       this.visible = true;
  492.    }
  493.    function hideSlide()
  494.    {
  495.       if(this.__transitionManager.numTransitions > 0)
  496.       {
  497.          this.__transitionManager.removeAllTransitions();
  498.          this.__transitionManager.restoreContentAppearance();
  499.       }
  500.       this.visible = false;
  501.    }
  502.    function doStop()
  503.    {
  504.       this.gotoAndStop(1);
  505.    }
  506.    function hideHandler(o)
  507.    {
  508.       if(!this.playHidden)
  509.       {
  510.          this.doLater(this,"doStop");
  511.       }
  512.       var _loc2_ = undefined;
  513.       _loc2_ = this;
  514.       while(_loc2_.parentIsSlide)
  515.       {
  516.          _loc2_ = _loc2_.parentSlide;
  517.          _loc2_.dispatchEvent({type:"hideChild",target:this});
  518.       }
  519.    }
  520.    function doPlay()
  521.    {
  522.       this._shown = true;
  523.       this.play();
  524.    }
  525.    function revealHandler(o)
  526.    {
  527.       if(!this._shown || !this.playHidden)
  528.       {
  529.          this.doLater(this,"doPlay");
  530.       }
  531.       var _loc2_ = undefined;
  532.       _loc2_ = this;
  533.       while(_loc2_.parentIsSlide)
  534.       {
  535.          _loc2_ = _loc2_.parentSlide;
  536.          _loc2_.dispatchEvent({type:"revealChild",target:this});
  537.       }
  538.    }
  539.    function childLoaded(obj)
  540.    {
  541.       super.childLoaded(obj);
  542.       var _loc5_ = {x:0,y:0};
  543.       this.globalToLocal(_loc5_);
  544.       obj.move(_loc5_.x,_loc5_.y);
  545.       if(obj._containedScreen._isSlide)
  546.       {
  547.          var _loc4_ = obj._containedScreen;
  548.          var _loc6_ = mx.screens.Slide(obj._parent);
  549.          obj._isSlideContainer = true;
  550.          obj._containedSlide = _loc4_;
  551.          _loc4_._indexInParentSlide = _loc6_._childSlides.push(_loc4_) - 1;
  552.          if(_loc6_.currentSlide)
  553.          {
  554.             this.doLater(_loc6_,"gotoFirstSlide");
  555.          }
  556.       }
  557.    }
  558.    function shouldHideDuringGoto()
  559.    {
  560.       if(this._childThatContainsGotoSlide != -1 || !this.parentIsSlide)
  561.       {
  562.          return false;
  563.       }
  564.       var _loc2_ = this.parentSlide;
  565.       var _loc3_ = this.indexInParent;
  566.       while(true)
  567.       {
  568.          if(_loc2_._childThatContainsGotoSlide != -1)
  569.          {
  570.             if(_loc3_ > _loc2_._childThatContainsGotoSlide)
  571.             {
  572.                return true;
  573.             }
  574.             if(_loc2_.overlayChildren)
  575.             {
  576.                return false;
  577.             }
  578.             return true;
  579.          }
  580.          if(!_loc2_.overlayChildren)
  581.          {
  582.             return true;
  583.          }
  584.          if(!_loc2_.parentIsSlide)
  585.          {
  586.             return false;
  587.          }
  588.          _loc3_ = _loc2_.indexInParent;
  589.          _loc2_ = _loc2_.parentSlide;
  590.       }
  591.       return false;
  592.    }
  593.    function destroyChildAt(childIndex)
  594.    {
  595.       var _loc3_ = this.getChildSlide(childIndex);
  596.       if(_loc3_ == this._currentChildSlide)
  597.       {
  598.          this.gotoSlide(this);
  599.       }
  600.       this._childSlides.splice(childIndex,1);
  601.       super.destroyChildAt(childIndex);
  602.    }
  603.    function allAncestorsVisible()
  604.    {
  605.       var _loc2_ = this;
  606.       while(_loc2_)
  607.       {
  608.          if(!_loc2_._visible)
  609.          {
  610.             return false;
  611.          }
  612.          _loc2_ = _loc2_._parent;
  613.       }
  614.       return true;
  615.    }
  616.    function isAncestor(a, o)
  617.    {
  618.       var _loc1_ = o;
  619.       while(_loc1_ && _loc1_ != a)
  620.       {
  621.          _loc1_ = _loc1_._parent;
  622.       }
  623.       return _loc1_ == a;
  624.    }
  625.    function hasMouseHandler(o)
  626.    {
  627.       if(o.onPress != undefined || o.onRelease != undefined || o.onReleaseOutside != undefined || o.onDragOut != undefined || o.onDragOver != undefined || o.onRollOver != undefined || o.onRollOut != undefined || o.delegateClick != undefined || o.clickHandler != undefined)
  628.       {
  629.          return true;
  630.       }
  631.       return false;
  632.    }
  633.    function getMousedChild(x, y, o)
  634.    {
  635.       for(var _loc7_ in o)
  636.       {
  637.          var _loc2_ = o[_loc7_];
  638.          if(_loc2_._parent == o)
  639.          {
  640.             if(_loc2_.hitTest(x,y,true))
  641.             {
  642.                if(this.hasMouseHandler(_loc2_))
  643.                {
  644.                   return _loc2_;
  645.                }
  646.                var _loc3_ = this.getMousedChild(x,y,_loc2_);
  647.                if(_loc3_ != undefined)
  648.                {
  649.                   return _loc3_;
  650.                }
  651.                return _loc2_;
  652.             }
  653.          }
  654.       }
  655.       return undefined;
  656.    }
  657.    function mouseDownSomewhereHandler(o)
  658.    {
  659.       var _loc6_ = _root._xmouse;
  660.       var _loc5_ = _root._ymouse;
  661.       if(this != this.rootSlide)
  662.       {
  663.          return undefined;
  664.       }
  665.       if(this.allAncestorsVisible() && this.hitTest(_loc6_,_loc5_,false))
  666.       {
  667.          var _loc4_ = this.getMousedChild(_loc6_,_loc5_,this);
  668.          var _loc7_ = this.getMousedChild(_loc6_,_loc5_,_root);
  669.          var _loc3_ = null;
  670.          if(_loc4_ == undefined && this.hitTest(_loc6_,_loc5_,true))
  671.          {
  672.             if(_loc7_ == this && !this.hasMouseHandler(this))
  673.             {
  674.                _loc3_ = this;
  675.             }
  676.          }
  677.          else if(this.isAncestor(_loc7_,_loc4_) && !this.hasMouseHandler(_loc4_))
  678.          {
  679.             if(_loc4_._isSlide)
  680.             {
  681.                _loc3_ = _loc4_;
  682.             }
  683.             else
  684.             {
  685.                _loc3_ = _loc4_;
  686.                while(_loc3_ && !_loc3_._isSlide)
  687.                {
  688.                   _loc3_ = _loc3_._parent;
  689.                }
  690.             }
  691.          }
  692.          if(_loc3_ && _loc3_.allAncestorsVisible() && mx.screens.Slide.currentFocusedSlide.rootSlide != _loc3_.rootSlide)
  693.          {
  694.             mx.screens.Slide._focusSeq = mx.screens.Slide._focusSeq + 1;
  695.             mx.screens.Slide._clickFocusSeq = mx.screens.Slide._focusSeq;
  696.             this.doLater(_loc3_.rootSlide.currentSlide,"clickSetFocus");
  697.          }
  698.       }
  699.    }
  700.    function clickSetFocus()
  701.    {
  702.       if(mx.screens.Slide._focusSeq == mx.screens.Slide._clickFocusSeq)
  703.       {
  704.          this.doLater(this,"setFocus");
  705.       }
  706.    }
  707. }
  708.